package com.hzhr.iot.device.controller;

import com.hzhr.iot.core.annotation.ApiImplicitInternalParams;
import com.hzhr.iot.core.annotation.Author;
import com.hzhr.iot.core.dto.ResponseExceptionDto;
import com.hzhr.iot.core.exception.ServiceException;
import com.hzhr.iot.device.controller.base.BaseController;
import com.hzhr.iot.device.model.concentrator_meter_collectData.Concentrator_Meter_CollectDataGetModel;
import com.hzhr.iot.device.service.Concentrator_Meter_CollectDataService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Map;

@Api(tags = "Concentrator_Meter_CollectData", description = "集中器下的表具的采集数据")
@RestController
@RequestMapping(value = "")
public class Concentrator_Meter_CollectDataController extends BaseController {
    @Autowired
    Concentrator_Meter_CollectDataService concentrator_meter_collectDataService;

    //region /concentrators/{concentratorId}/meters/{meterId}/collect-datas GET
    //region swagger响应码 : getByConcentratorIdAndId
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
            @ApiResponse(code = 403, message = "----异常代码 : 201  \n----异常类型 : 业务流程异常  \n----异常业务 : 验证表具的存在性  \n----异常说明 : 表具不存在  \n\n", response = ResponseExceptionDto.class),
    })
    //endregion
    //region swagger说明 : getByConcentratorIdAndId
    @ApiOperation(value="查询用户所在物联网设备公司下的集中器下的表具的采集数据", notes="查询用户所在物联网设备公司下的集中器下的表具的采集数据  \n简介 : 查询用户所在物联网设备公司下的集中器下的表具的采集数据  \n步骤 :  \n1. 验证集中器下表具的存在性 :  \n如果不存在CollectDeviceEntityExt对象满足以下条件，则抛出异常201：  \n          CollectDeviceEntityExt.id = 路径参数meterId；  \n          CollectDeviceEntityExt.iotDeviceId = 路径参数concentratorId；  \n          CollectDeviceEntityExt.iotDeviceExt.companyId = 登录用户.companyId；  \n2. 查询集中器下的表具的采集数据 :  \n根据条件参数查询CollectDataEntity对象列表collectDataList_1及总数，  \n额外查询条件如下：  \n          CollectDataEntity.collectDeviceId = 路径参数meterId；  \n3. 返回信息 :  \n根据条件参数，将collectDataList_1及总数组装成结果对象并返回；  \n",produces = "application/json")
    //endregion
    //region swagger参数 : getByConcentratorIdAndId
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "concentratorId", value = "集中器编号",required = true, dataType = "int", paramType = "path"),
            @ApiImplicitParam(name = "meterId", value = "表具编号",required = true, dataType = "int", paramType = "path"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_id", value = "筛选条件 : where Concentrator_Meter_CollectDataModel.id = #{equal_id}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_valveStatusCode", value = "筛选条件 : where Concentrator_Meter_CollectDataModel.valveStatusCode = #{equal_valveStatusCode}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "greaterthanorequal_currentTm", value = "筛选条件 : where Concentrator_Meter_CommandModel.currentTm >= #{greaterthanorequal_currentTm}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "lessthan_currentTm", value = "筛选条件 : where Concentrator_Meter_CommandModel.currentTm < #{lessthan_currentTm}",required = false, dataType = "int", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_id", value = "筛选条件 : where Concentrator_Meter_CollectDataModel.id = #{_equal_id}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_valveStatusCode", value = "筛选条件 : where Concentrator_Meter_CollectDataModel.valveStatusCode = #{_equal_valveStatusCode}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_greaterthanorequal_currentTm", value = "筛选条件 : where Concentrator_Meter_CommandModel.currentTm >= #{_greaterthanorequal_currentTm}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_lessthan_currentTm", value = "筛选条件 : where Concentrator_Meter_CommandModel.currentTm < #{_lessthan_currentTm}",required = false, dataType = "int", paramType = "query"),

    })
    //endregion
    //region 请求 : getByConcentratorIdAndId
    @RequestMapping(value = "/concentrators/{concentratorId}/meters/{meterId}/collect-datas", method = RequestMethod.GET)
    //endregion
    @Author
    public ResponseEntity<Concentrator_Meter_CollectDataGetModel> getByConcentratorIdAndId(@PathVariable("concentratorId") Integer concentratorId,
                                                                                           @PathVariable("meterId") Integer meterId,
                                                                                           @RequestParam @ApiIgnore Map<String, Object> query) throws ServiceException {
        Concentrator_Meter_CollectDataGetModel responseBody = concentrator_meter_collectDataService.getByConcentratorIdAndId(initHeader(), concentratorId, meterId, query);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
        //endregion
    }
    //endregion

}


















































































































































































































































































































































































































































































































































































































